package kgame5.kgui.kcomp.tappane {
import flash.display.MovieClip;
import flash.events.MouseEvent;

/**
 * @author kk
 * 标签条，每个mc_pane.mc_head被点了则移到最前
 * 先弄个简单直观的，以后再说扩展
 */
public class SmartTapPaneGroup {
	private var mc_c:MovieClip;
	private var aTapPane:Array;
	public function SmartTapPaneGroup(p_mc_c:MovieClip){
		mc_c=p_mc_c;
		aTapPane=new Array();
		for (var i:int=0;i<mc_c.numChildren;i++){
			var mc_pane:MovieClip=mc_c.getChildAt(i) as MovieClip;
				var mc_head:MovieClip=mc_pane.mc_head;
			mc_head.addEventListener(MouseEvent.CLICK, onClickHead);
			aTapPane.push(mc_pane);
		}
	}
	private function onClickHead(e:MouseEvent){
		var mc_head:MovieClip=e.currentTarget as MovieClip;
		var mc_pane:MovieClip=mc_head.parent as MovieClip;
		
		setCurrent(mc_pane.name);
	}
	//设置当前显示的
	public function setCurrent(sName:String){
		//显示选中过的层级的
		var aimIdx:int = mc_c.numChildren-1;
		mc_c.setChildIndex(mc_c.getChildByName(sName), aimIdx);
		
		//各个pane背景变一下
		for each(var mc_pane:MovieClip in aTapPane){
			if(mc_pane.name!=sName){
				mc_pane.mc_bg.gotoAndStop(2);
			}else{
				mc_pane.mc_bg.gotoAndStop(1);
			}
		}
	}
}//end of class
}
